package com.xiaochen.baidu.common.design.combination.logic;

import com.xiaochen.baidu.common.design.combination.engine.model.vo.TreeNodeLink;

import java.util.List;
import java.util.Map;

/**
 * @author xc
 * @date 2025/10/11/15:27
 * @desc
 */
public abstract class BaseLogic<T> implements LogicFilter<T>{
    @Override
    public Long filter(T matterValue, List<TreeNodeLink> treeNodeLineInfoList) {
        return treeNodeLineInfoList.stream()
                .filter(treeNodeLink -> matterValue.equals(treeNodeLink.getRuleLimitType()))
                .findFirst()
                .map(TreeNodeLink::getNodeIdTo)
                .orElse(0L);
    }

    @Override
    public abstract T matterValue(Long treeId, Map<String, T> decisionMatter);
}
